import java.util.*;

public class Colote {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        List<String> list = new LinkedList<>();
        String[] s1 = s.split(" ");

        for (String S:
                s1) {
            list.add(S);
        }
        int i = 0;
        for (;i < list.size(); i++) {
            if(list.get(i).startsWith("王")) {

                System.out.println(list.get(i) + "被移除了...");
                list.remove(i);
            }
        }
        for (int j = list.size()-1; j >=0; j--) {

            System.out.println(list.get(j));
        }
    }

}
